import 'package:flutter_fronter_service/generated/json/base/json_convert_content.dart';
import 'package:flutter_fronter_service/model/user_entity.dart';

UserEntity $UserEntityFromJson(Map<String, dynamic> json) {
  final UserEntity userEntity = UserEntity();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    userEntity.id = id;
  }
  final String? userPhone = jsonConvert.convert<String>(json['userPhone']);
  if (userPhone != null) {
    userEntity.userPhone = userPhone;
  }
  final String? userName = jsonConvert.convert<String>(json['userName']);
  if (userName != null) {
    userEntity.userName = userName;
  }
  final String? userAvatar = jsonConvert.convert<String>(json['userAvatar']);
  if (userAvatar != null) {
    userEntity.userAvatar = userAvatar;
  }
  final String? userRole = jsonConvert.convert<String>(json['userRole']);
  if (userRole != null) {
    userEntity.userRole = userRole;
  }
  return userEntity;
}

Map<String, dynamic> $UserEntityToJson(UserEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['userPhone'] = entity.userPhone;
  data['userName'] = entity.userName;
  data['userAvatar'] = entity.userAvatar;
  data['userRole'] = entity.userRole;
  return data;
}

extension UserEntityExtension on UserEntity {
  UserEntity copyWith({
    int? id,
    String? userPhone,
    String? userName,
    String? userAvatar,
    String? userRole,
  }) {
    return UserEntity()
      ..id = id ?? this.id
      ..userPhone = userPhone ?? this.userPhone
      ..userName = userName ?? this.userName
      ..userAvatar = userAvatar ?? this.userAvatar
      ..userRole = userRole ?? this.userRole;
  }
}